﻿// ———————————————————————–
// <copyright file="ValueListView.cs" company="The MITRE Corporation">
//    Copyright (c) 2010 The MITRE Corporation. All rights reserved.
//    Licensed under the Apache License, Version 2.0 (the "License");
//    you may not use this file except in compliance with the License.
//    You may obtain a copy of the License at
//    http://www.apache.org/licenses/LICENSE-2.0
//    Unless required by applicable law or agreed to in writing, software
//    distributed under the License is distributed on an "AS IS" BASIS,
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//    See the License for the specific language governing permissions and
//    limitations under the License.
// </copyright>
// ———————————————————————–
/////////////////////////////////////////////////////////////////////////////////////////////////
// ValueListView.cs - Library Class for the EDXL-DE Message
// Project: IC.NET - EDXL Library
//
// Language:    C#, .NET 4.0
// Platform:    Windows 7, VS 2010 Beta 2
// Author:      Joseph Whitmore, Bedford

/////////////////////////////////////////////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using EDXLSharp;

namespace EDXLSharp.EDXLTestApplication
{
  /// <summary>
  /// Form to display a ValueList Object
  /// </summary>
  public partial class ValueListView : Form
  {
    /// <summary>
    /// Pixels to vertically shift text down
    /// </summary>
    private static int vdrop = 10;
    
    /// <summary>
    /// Line height in pixels
    /// </summary>
    private static int lineHeight = 20;
    
    /// <summary>
    /// Pixels to indent text
    /// </summary>
    private static int lineIndent = 10;

    /// <summary>
    /// Initializes a new instance of the ValueListView class
    /// </summary>
    public ValueListView()
    {
      this.InitializeComponent();
    }

    /// <summary>
    /// Populate the ValueList viewer form with the specified ValueList and title
    /// </summary>
    /// <param name="vl">ValueList object to be displayed</param>
    /// <param name="title">Title to be displayed on the form window</param>
    public void VLV(ValueList vl, string title)
    {
      if (vl != null)
      {
        int line = vdrop;
        Label urntitle = new Label();
        urntitle.Text = vl.ValueListURN;
        urntitle.Font = new Font(urntitle.Font, FontStyle.Bold);
        urntitle.Location = new Point(lineIndent / 2, line);

        line += 2 * lineHeight;
        if (title != null)
        {
          this.Text = title;
        }
        else
        {
          this.Text = vl.ValueListURN;
        }
        
        foreach (string str in vl.Value)
        {
          Label vlv = new Label();
          vlv.Location = new Point(lineIndent, line);
          vlv.Text = str;
          this.Controls.Add(vlv);
          line += lineHeight;
        }

        this.Show();
      }
      else
      {
        this.Close();
      }
    }

    /// <summary>
    /// To be used to load a ValueList object
    /// </summary>
    /// <param name="sender">Object generating event</param>
    /// <param name="e">Event generated by object</param>
    private void ValueListView_Load(object sender, EventArgs e)
    {
      // place holder
    }
  }
}
